import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { DeviceTelemetryForm, DeviceTelemetryQuery, DeviceTelemetryVO } from './types';

/**
 * 查询设备工况列表
 * @param query
 * @returns {*}
 */

export const listDeviceTelemetry = (query?: DeviceTelemetryQuery): AxiosPromise<DeviceTelemetryVO[]> => {
  return request({
    url: '/iot/deviceTelemetry/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询设备工况详细
 * @param deviceTelemetryId
 */
export const getDeviceTelemetry = (deviceTelemetryId: string | number): AxiosPromise<DeviceTelemetryVO> => {
  return request({
    url: '/iot/deviceTelemetry/' + deviceTelemetryId,
    method: 'get'
  });
};

/**
 * 新增设备工况
 * @param data
 */
export const addDeviceTelemetry = (data: DeviceTelemetryForm) => {
  return request({
    url: '/iot/deviceTelemetry',
    method: 'post',
    data: data
  });
};

/**
 * 修改设备工况
 * @param data
 */
export const updateDeviceTelemetry = (data: DeviceTelemetryForm) => {
  return request({
    url: '/iot/deviceTelemetry',
    method: 'put',
    data: data
  });
};

/**
 * 删除设备工况
 * @param deviceTelemetryId
 */
export const delDeviceTelemetry = (deviceTelemetryId: string | number | Array<string | number>) => {
  return request({
    url: '/iot/deviceTelemetry/' + deviceTelemetryId,
    method: 'delete'
  });
};
